{% extends 'base1.html' %}
{% load staticfiles %}
{% block title %}种子信息管理 - 人员详情{% endblock %}
{% block custome_css %}
    <link rel="stylesheet" href="{% static 'servers/css/server-add.css' %}">
    <link rel="stylesheet" href="{% static 'servers/css/server-detail.css' %}">
{% endblock %}
{% block content %}
    <div class="content">
        <p class="content-note1">修改人员<span class="content-note2"> (标注为*为必填项)</span></p>
        <div style="clear:both"></div>
        <form class="form-table" action="{% url 'users:user_modify' %}" method="post">
            <input type="hidden" id="user_id" name="user_id" value="{{ user.id }}"/>
            <div class="form-list">
                <span>*姓名</span><input {% if userinfo_form.errors.username %}class="input-error"{% endif %} type="text" id="username" name="username" value="{{ user.username }}"/>
            </div>
            <div class="form-list">
                <span>学号/工号</span><input {% if userinfo_form.errors.staff_no %}class="input-error"{% endif %} type="text" id="staff_no" name="staff_no" value="{{ user.staff_no }}"/>
            </div>
            <div class="form-list">
                <span>实验室/办公室</span><input {% if userinfo_form.errors.department %}class="input-error"{% endif %} type="text" name="department" value="{{ user.department }}" placeholder="不超过15个字符"/>
            </div>
            <div class="form-list">
                <span>办公电话</span><input {% if userinfo_form.errors.bg_telephone %}class="input-error"{% endif %} type="text" name="bg_telephone" value="{{ user.bg_telephone }}" placeholder="不超过12个字符，区号用-隔开"/>
            </div>
            <div class="form-list">
                <span>手机号码</span><input {% if userinfo_form.errors.mobile %}class="input-error"{% endif %} type="text" name="mobile" value="{{ user.mobile }}" placeholder="不超过11个字符"/>
            </div>
            <div class="form-list">
                <span>邮箱</span><input type="text" name="email" value="{{ user.email }}" placeholder="不超过30个字符"/>
            </div>
            <div class="form-list">
                <span>管理员</span>
                <select name="isadmin">
                    <option value="1" {% ifequal user.isadmin '1' %}selected{% endifequal %}>是</option>
                    <option value="0" {% ifequal user.isadmin '0' %}selected{% endifequal %}>否</option>
                </select>
            </div>
            <div class="form-list">
                <span>在校</span>
                <select name="is_staff">
                    <option value="1" {% ifequal user.is_staff "1" %}selected{% endifequal %}>是</option>
                    <option value="0" {% ifequal user.is_staff "0" %}selected{% endifequal %}>否</option>
                </select>
            </div>
            {% if msg %}
                <div class="error">{{ msg }}</div>
            {% endif %}
            <div style="clear:both"></div>
            <div class="form-list">
                <input class="form-button" type="submit" value="保存"/>
            </div>
            <div class="form-list">
                 <button class="form-button" type="button" onclick="btn_cancel()">取消</button>
            </div>
{#            <div class="form-list">#}
{#                 <button class="form-button form-button-del" type="button" onclick="btn_delete()">删除</button>#}
{#            </div>#}
            <div class="form-list">
                 <button class="form-button form-button-pwdreset" type="button" onclick="btn_pwdreset()">重置密码</button>
            </div>
            {% csrf_token %}
        </form>
</div>
{% endblock %}
{% block custome_js %}
    <script>
        function btn_cancel() {
            location.href = "{% url 'users:user_list' %}";
        }

        function btn_delete() {
            var user_id = document.getElementById("user_id").value;
            var username = document.getElementById("username").value;
            var url = "{% url 'users:user_delete' 0 %}";
            var conf = confirm("确定删掉用户 "+username+" ？");
            if (conf) {
                location.href = url.replace('0', user_id);
            }
        }

        function btn_pwdreset() {
            var user_id = document.getElementById("user_id").value;
            var url = "{% url 'users:user_pwdreset' 0 %}";
            location.href = url.replace('0', user_id);
        }
    </script>
{% endblock %}


user_pwdreset